package library;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Gedsimon Pereira - 58554
 * @contact gspas@iscte.pt
 * 
 */
public class StringFilter implements Serializable {

	private static final long serialVersionUID = -289244560042918152L;
	private List<String> lstString = new ArrayList<String>();
	private List<String> filteredStrings = new ArrayList<String>();

	public void addFilter(Filter filter) {
		if (!filteredStrings.isEmpty()) {
			lstString = filteredStrings;
		}
		filteredStrings = new ArrayList<String>();
		for (String valueAccept : lstString) {
			if (filter.accept(valueAccept)) {
				filteredStrings.add(valueAccept);
			} else {
				filteredStrings.remove(valueAccept);
			}
		}
	}

	public void addWord(String value) {
		lstString.add(value);
	}

	/**
	 * @param list
	 */
	public void addStrings(ArrayList<String> list) {
		if (!list.isEmpty()) {
			lstString.addAll(list);
			filteredStrings.addAll(list);
		}
	}

	/**
	 * @return the lstString
	 */
	public List<String> getLstString() {
		return lstString;
	}

	/**
	 * @param lstString
	 *            the lstString to set
	 */
	public void setLstString(List<String> lstString) {
		this.lstString = lstString;
	}

	/**
	 * @return the filteredStrings
	 */
	public List<String> getFilteredStrings() {
		return filteredStrings;
	}

	/**
	 * @param filteredStrings
	 *            the filteredStrings to set
	 */
	public void setFilteredStrings(List<String> filteredStrings) {
		this.filteredStrings = filteredStrings;
	}

}
